<!DOCTYPE html>
<head>
<script src="../../resources/js-test.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
</head>
<body onload="setTimeout(startTest, 1)">
<input name="name1" id="input1">
<iframe id="frame1" src="resources/form-state-restore-with-frames-1.html">
</iframe>
<form id="form1" action="../../resources/back.html">
<input type="submit">
</form>

<script>
function $(id) {
    return document.getElementById(id);
}
function frame$(frame, id) {
    return frame.contentDocument.getElementById(id);
}

function startTest() {
    if ($('input1').value == 'visited') {
        shouldBeEqualToString('frame$($("frame1"), "input2").value', 'value2');
        shouldBeEqualToString('frame$(frame$($("frame1"), "frame2"), "input3").value', 'value3');
        finishJSTest();
    } else {
        $('input1').value = 'visited';
        frame$($('frame1'), 'input2').value = 'value2';
        frame$(frame$($('frame1'), 'frame2'), 'input3').value = 'value3';
        $('form1').submit();
    }
}

jsTestIsAsync = true;
</script>
</body>
